# coding=utf-8
# -*- coding: UTF-8 -*-
#
# This file is part of the kernelstudio package.
#
# (c) 2014-2025 zlin <admin@kernelstudio.com>
#
# For the full copyright and license information, please view the LICENSE file
# that was distributed with this source code.
import typing as t

from ksai.persistence.database import db
from ksai.query import Query
from ksai.serializer import JsonSerializable


class DocumentLabelsModelQuery(Query):

    def __init__(self):
        super().__init__()


class DocumentLabelsModel(db.Model, JsonSerializable):
    __tablename__ = 'ksai_document_labels'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    uuid = db.Column(db.String(60), unique=True, nullable=False)
    parent_uuid = db.Column(db.String(60), nullable=False, default="0")
    name = db.Column(db.String(120), nullable=True)
    type = db.Column(db.String(120), nullable=True, default='string')
    created_at = db.Column(db.DateTime(timezone=True), default=None, nullable=True)
    updated_at = db.Column(db.DateTime(timezone=True), default=None, nullable=True)
    deleted_at = db.Column(db.DateTime(timezone=True), default=None, nullable=True)

    def serialize(self) -> t.Optional[dict]:
        return {
            "uuid": self.uuid,
            "parent_uuid": self.parent_uuid,
            "name": self.name,
            "type": self.type,
            "created_at": self.created_at,
            "updated_at": self.updated_at
        }
